import request from '@/utils/request';

const BATCH_BASE_URL = '/nljs/report/batch';

const BatchAPI = {
  // 新增填报批次
  addBacth(data: any) {
    return request({
      url: `${BATCH_BASE_URL}/add`,
      method: 'post',
      data,
    });
  },
  // 修改填报批次
  editBatch(data: any) {
    return request({
      url: `${BATCH_BASE_URL}/update`,
      method: 'post',
      data,
    });
  },
  // 删除填报批次
  delBatch(id: string | number) {
    return request({
      url: `${BATCH_BASE_URL}/delete/${id}`,
      method: 'post',
    });
  },
  // 分页查询填报批次
  getBatchList(data: any) {
    return request({
      url: `${BATCH_BASE_URL}/page`,
      method: 'get',
      params: data,
      // headers: {
      //   'Content-Type': 'application/x-www-form-urlencoded'
      // }
    });
  },
  // 查询填报批次列表（无分页）
  getBatchAllList(data: any) {
    return request({
      url: `${BATCH_BASE_URL}/list`,
      method: 'get',
      params: data,
    });
  },
  // 获取填报批次详情
  getBatchDetail(id: string | number) {
    return request({
      url: `${BATCH_BASE_URL}/${id}`,
      method: 'get',
    });
  },
  // 获取批次关联的表单ID列表
  getRelatedList(batchId: string | number) {
    return request({
      url: `${BATCH_BASE_URL}/forms/${batchId}`,
      method: 'get',
    });
  },
  // 获取当前有效的填报批次列表
  getEffectiveList() {
    return request({
      url: `${BATCH_BASE_URL}/active`,
      method: 'get',
    });
  },
  // 批量删除填报批次
  batchDel(data: number[] | string[]) {
    return request({
      url: `${BATCH_BASE_URL}/batch/batch-delete`,
      method: 'post',
      data,
    });
  },
  // 发布填报批次
  pushBatch(data: any = {}, batchId: string) {
    return request({
      url: `${BATCH_BASE_URL}/publish/${batchId}`,
      method: 'post',
      data,
    });
  },
  // 获取批次统计数据
  getStatistics(queryParams?: any) {
    return request({
      url: `${BATCH_BASE_URL}/statistics`,
      method: 'get',
      params: queryParams,
    });
  },
};

export default BatchAPI;

/** 登录用户信息 */
export interface BatchInfo {
  // 批次id
  id: number | string;
  name: string;
  remark: string;
}
